* Multiproduct Firms, Horizontal Mergers, and International Trade
* Jackie M.L. Chan, Michael Irlacher, and Michael Koch

* This do file runs the main regressions for export market outcomes.

use "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\data\regression_data_export.dta", clear

* Table A.12
foreach x in lnnmark lnnprod {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25 if minemployee_cvrnr>=5 & _mergedist==3, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A12.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25) bdec(4) sdec(4) nocons nonotes 
}

foreach x in lnnprodpermark {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25 if minemployee_cvrnr>=5 & ((acquirer==1 & max_merge==3) | acquirer==0) & _mergedist==3, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A12.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25) bdec(4) sdec(4) nocons nonotes 
}

foreach x in p90_ldistw lnanprodpermark {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25 if minemployee_cvrnr>=5 & _mergedist==3, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A12.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25) bdec(4) sdec(4) nocons nonotes
}

* Figure A.5(b)
foreach x in nmark nprod {
ppmlhdfe `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25 if minemployee_cvrnr>=5 & (_mergedist==3 | `x'==0), absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA5.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25) bdec(4) sdec(4) nocons nonotes
}

* Figure A.8(a)
foreach x in p90_lr_ltradingimportdocs p90_lr_ltradingimporttime p90_lr_ltradingimportcost_def {	
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25 if minemployee_cvrnr>=5 & _mergedist==3, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA8.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_25) bdec(4) sdec(4) nocons nonotes 
}

* Figure A.9(c), (d)
foreach x in lnnmark lnnprod {
areg `x' p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_25 if minemployee_cvrnr>=5 & ((acquirer==1 & d_yr<1) | acquirer==0) & _mergedist==3, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA9.txt", keep(p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_25) bdec(4) sdec(4) nocons nonotes 
}

foreach x in lnnprodpermark {
areg `x' p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_25 if minemployee_cvrnr>=5 & ((acquirer==1 & max_merge==3 & d_yr<1) | acquirer==0) & _mergedist==3, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA9.txt", keep(p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_25) bdec(4) sdec(4) nocons nonotes 
}

foreach x in p90_ldistw {
areg `x' p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_25 if minemployee_cvrnr>=5 & ((acquirer==1 & d_yr<1) | acquirer==0) & _mergedist==3, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA9.txt", keep(p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_25) bdec(4) sdec(4) nocons nonotes 
}

rename theil_fy theil_fy_exp

merge 1:1 cvrnrA aarA using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\data\temp_vars_dom_all_cvrnr_dro.dta", keep(match master) nogen

merge 1:1 cvrnrA aarA using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\data\temp_vars_com_all_cvrnr.dta", keep(match master) nogen

gen lnvrdA_dom_dro = ln(vrdA_dom_dro)
gen lnvrdA_exp = ln(vrdA)
gen lnvrdA_vars = ln(vrdA_vars)

* Table A.15
foreach x in lnnmark lnanprodpermark {
areg `x' lnvrdA_dom_dro theil_fy_dro D_AA_1-D_AA_25 if minemployee_cvrnr>=10 & (acquirer==0) & _mergedist==3 & theil_fy_dro!=. & aarA>=1996, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A15.txt", bdec(4) sdec(4) nocons nonotes 

areg `x' lnvrdA_vars theil_fy_vars D_AA_1-D_AA_25 if minemployee_cvrnr>=10 & (acquirer==0) & _mergedist==3 & theil_fy_dro!=. & aarA>=1996, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A15.txt", bdec(4) sdec(4) nocons nonotes 
}

* Figure A.8(c)
foreach x in p90_lr_ltradingimportdocs p90_lr_ltradingimporttime p90_lr_ltradingimportcost_def {	
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=5 & _mergedist==3, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA8.txt", bdec(4) sdec(4) nocons nonotes
}

* Figure A.11
foreach x in lnnmark lnnprod {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=5 & _mergedist==3, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA11.txt", bdec(4) sdec(4) nocons nonotes 
}

foreach x in lnnprodpermark {	
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=5 & ((acquirer==1 & max_merge==3) | acquirer==0) & _mergedist==3, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA11.txt", bdec(4) sdec(4) nocons nonotes
}

foreach x in p90_ldistw {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=5 & _mergedist==3, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA11.txt", bdec(4) sdec(4) nocons nonotes 
}

* Figure A.13(c),(d)
foreach x in lnnmark lnnprod {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=5 & minnprod>1 & _mergedist==3, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA13.txt", bdec(4) sdec(4) nocons nonotes
}

foreach x in lnnprodpermark {	
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=5 & minnprod>1 & ((acquirer==1 & max_merge==3) | acquirer==0) & _mergedist==3, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA13.txt", bdec(4) sdec(4) nocons nonotes 
}

foreach x in p90_ldistw {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=5 & minnprod>1 & _mergedist==3, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA13.txt", bdec(4) sdec(4) nocons nonotes 
}
